package com.wiscamp.ninechapters.common.rest;

import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;

/**
 * REST服务HTTP响应包装类
 *
 * @param <T>
 * @author yifeng
 */
@Data
@EqualsAndHashCode
public class RestResponse<T> implements Serializable {
    private static final long serialVersionUID = -5148686695725152053L;

    private String code;

    private String message;

    private Meta meta;

    private T data;

    private String stackTrace;

    public RestResponse() {
    }

    public RestResponse(String code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public RestResponse(String code, String message, T data, String stackTrace) {
        this.code = code;
        this.message = message;
        this.data = data;
        this.stackTrace = stackTrace;
    }

    public RestResponse(String code, String message, T data, Meta meta) {
        this(code, message, data);
        this.meta = meta;
    }
}
